<?php
	class classTemplate{
		public function getActual($sPathToRoot=''){
            //template from cookie
            if(_GET_TEMPLATE_FROM_COOKIE_=='YES'){
                $_input     = new classInput();
                $_sess      = new classSessions();
                $URL_TName  = trim($_input->Sterilize($_GET[_TEMPLATE_URL_NAME_]));
                $SES_Value  = $_sess->open(_TEMPLATE_COOKIE_NAME_);

                if(
                    $URL_TName != '' and
                    file_exists(_TEMPLATE_DIR_.'/'.$URL_TName)
                ){
                    $_sess->serializeIt($URL_TName);
                    return _TEMPLATE_DIR_.'/'.$URL_TName;
                }
                elseif(
                    $URL_TName  =='' and
                    $SES_Value  != '' and
                    file_exists(_TEMPLATE_DIR_.'/'.$SES_Value)
                ){                   
                    return _TEMPLATE_DIR_.'/'.$SES_Value;
                }
            }     

            //normal type of getting template's name
			if(file_exists($sPathToRoot.'plugins/template/templateActive.inc')){
				$fileActiveSkin = fopen($sPathToRoot.'plugins/template/templateActive.inc','r');
				$result = $sPathToRoot._TEMPLATE_DIR_.'/'.fgets($fileActiveSkin,127);
				fclose($fileActiveSkin);
				
				return $result;
			}
			else{
				return '-1';
			}			
		}
        public function setActual($LocaleName, $sPathToRoot=''){
            if(file_exists($sPathToRoot.'plugins/template/templateActive.inc')){
                $result = file_put_contents($sPathToRoot.'plugins/template/templateActive.inc',$LocaleName);
				return $result;
			}
			else{
				return '-1';
			}
        }
	}
?>